﻿namespace ParkingLot3
{
    public class ParkingLotManagerOfEmptyCountFirst : ParkingLotManagerBase
    {
        /// <summary>
        /// 有一个停⻋小弟管理着两个停⻋场，他的停⻋策略是把⻋停到空位最多的停⻋场
        /// </summary>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public override ParkingLot ChooseParkLot()
        {
            if (parkingLots == null || parkingLots.Count() != 2)
                throw new Exception("停车场初始化错误");
            if (parkingLots.ToList()[0].IsParkingLotFull()&& parkingLots.ToList()[1].IsParkingLotFull())
                throw new Exception("没有可用停车场");
            if (parkingLots.ToList()[0].GetEmptyNumber() >= parkingLots.ToList()[1].GetEmptyNumber())
                return parkingLots.ToList()[0];
            return parkingLots.ToList()[1];
            
        }
    }
}
